package com.gitee.mapper;

import com.gitee.dto.FriendUpdatesStatesDTO;
import com.gitee.entity.FriendUpdatesStates;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Delete;
import java.util.List;

@Mapper
public interface FriendUpdatesStatesMapper {

    @Select("select * from sxq_friend_updates_states where user_id = #{userId} and friend_updates_id = #{friendUpdatesId}")
    FriendUpdatesStates selectByUserIdAndFriendUpdatesId(@Param("userId") Integer userId, @Param("friendUpdatesId") Integer friendUpdatesId);

    @Insert("insert into sxq_friend_updates_states values(null,#{friendUpdatesId},#{userId},#{hitsState},#{likeState},#{collectState})")
    void insert(FriendUpdatesStates friendUpdatesStates);

    void updateByFriendUpdatesIdAndUserId(FriendUpdatesStates friendUpdatesStates);

    @Select("select count(*) from sxq_friend_updates_states where hits_state = 1 and friend_updates_id = #{friendUpdatesId}")
    Integer countHits(Integer friendUpdatesId);

    @Select("select count(*) from sxq_friend_updates_states where like_state = 1 and friend_updates_id = #{friendUpdatesId}")
    Integer countLike(Integer friendUpdatesId);

    @Select("select count(*) from sxq_friend_updates_states where collect_state = 1 and friend_updates_id = #{friendUpdatesId}")
    Integer countCollect(Integer friendUpdatesId);

    @Select("select friend_updates_id from sxq_friend_updates_states where collect_state = 1 and user_id = #{userId}")
    List<Integer> selectCollectionByUserId(Integer userId);

    @Delete("delete from sxq_friend_updates_states where friend_updates_id = #{friendUpdateId}")
    void deleteByFriendUpdatesId(Integer friendUpdateId);
}
